package dto

import (
	"tuowei.com/app/admin/models"
	"tuowei.com/common/dto"
	common "tuowei.com/common/models"
)

type SysExaminationGetPageReq struct {
	dto.Pagination `search:"-"`
	Name           string `form:"name" search:"type:contains;column:name;table:sys_examination" comment:"名称"` // 名称
	Type           string `form:"type" search:"type:exact;column:ex_type;able:sys_examination" comment:"名称"`
	Subject        string `form:"subject" search:"type:exact;column:subject;table:sys_examination" comment:"名称"`
	Status         int    `form:"status" search:"type:exact;column:status;table:sys_examination" comment:"状态"` // 状态
}

func (m *SysExaminationGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type SysExaminationInsertReq struct {
	Id                   int    `json:"id" comment:"主键ID"`
	Name                 string `json:"name" comment:"试卷名称" vd:"@:len($)>0; msg:'试卷名称不能为空'"`
	Subject              string `json:"subject" comment:"科目" vd:"@:len($)>0; msg:'请选择科目'"`
	Description          string `json:"description" comment:"描述"`
	Province             string `json:"province" comment:"适用地区" vd:"@:len($)>0; msg:'适用地区不能为空'"`
	Status               int    `json:"status" gorm:"size:1;column:status"`
	Cover                string `json:"cover" gorm:"varchar(255);comment:封面地址"`
	ExaminationDuration  int    `json:"examination_duration" comment:"考试时长，单位为分钟"`
	StartExaminationTime string `json:"start_examination_time" gorm:"varchar(100);comment:开考时间"`
	IsFreePublic         int    `json:"is_free_public" comment:"是否免费公开 1公开2不公开"`
	common.ControlBy
}

func (s *SysExaminationInsertReq) GetId() interface{} {
	return s.Id
}

func (s *SysExaminationInsertReq) Generate(model *models.SysExamination) {
	//model.CourseId = s.CourseId
	model.Name = s.Name
	model.ExType = ""
	model.Description = s.Description
	model.Subject = s.Subject
	model.PublicRange = ""
	model.Status = s.Status
	model.Province = s.Province
	model.CreateBy = s.CreateBy
	model.Creator = s.Creator
	model.Cover = s.Cover
	model.ExaminationDuration = s.ExaminationDuration
	model.StartExaminationTime = s.StartExaminationTime
	model.IsFreePublic = s.IsFreePublic
}

type SysExaminationUpdateReq struct {
	Id                   int    `json:"id" comment:"主键ID" vd:"$>0;msg:'更新ID不能为空'"`
	Name                 string `json:"name" comment:"试卷名称" vd:"@:len($)>0; msg:'试卷名称不能为空'"`
	ExType               string `json:"ex_type" comment:"试卷类型" `
	Subject              string `json:"subject" comment:"科目" vd:"@:len($)>0; msg:'请选择科目'"`
	Description          string `json:"description" comment:"描述"`
	PublicRange          string `json:"public_range" comment:"公开范围" vd:"@:len($)>0; msg:'请选择公开范围'"`
	Province             string `json:"province" comment:"适用地区" vd:"@:len($)>0; msg:'适用地区不能为空'"`
	Status               int    `json:"status" gorm:"size:1;column:status"`
	Cover                string `json:"cover" gorm:"varchar(255);comment:封面地址"`
	ExaminationDuration  int    `json:"examination_duration" comment:"考试时长，单位为分钟"`
	StartExaminationTime string `json:"start_examination_time" gorm:"varchar(100);comment:开考时间"`
	IsFreePublic         int    `json:"is_free_public" gorm:"int(5);default:1;comment:是否免费公开 1公开2不公开"`
	common.ControlBy
}

func (s *SysExaminationUpdateReq) Generate(model *models.SysExamination) {
	//model.CourseId = s.CourseId
	if s.Id != 0 {
		model.Id = s.Id
	}
	model.Name = s.Name
	model.ExType = s.ExType
	model.Subject = s.Subject
	model.Description = s.Description
	model.PublicRange = s.PublicRange
	model.Status = s.Status
	model.UpdateBy = s.UpdateBy
	model.Updater = s.Updater
	model.Cover = s.Cover
	model.ExaminationDuration = s.ExaminationDuration
	model.StartExaminationTime = s.StartExaminationTime
	model.IsFreePublic = s.IsFreePublic
	model.Province = s.Province
}

func (s *SysExaminationUpdateReq) GetId() interface{} {
	return s.Id
}

type SysExaminationById struct {
	dto.ObjectById
	common.ControlBy
}
